home *** CD-ROM | disk | FTP | other *** search
/ mail.altrad.com / 2015.02.mail.altrad.com.tar / mail.altrad.com / TEST / office deutch / INFOPATH.NL-NL / INFLR.CAB / FL_InferaSchemafromanXmlFile_snippet_142733_ENU____.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Extensible Markup Language  |  2005-10-28  |  2KB  |  55 lines

  1. ∩╗┐<?xml version="1.0" encoding="UTF-8"?>
  2. <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  3.   <CodeSnippet Format="1.0.0">
  4.     <Header>
  5.       <Title>Infer and create a Schema from an XML file.</Title>
  6.       <Author>Microsoft Corporation</Author>
  7.       <Description>Infers a Schema from an existing XML file and saves it as a seperate schema file.</Description>
  8.       <Shortcut>xmlInfer</Shortcut>
  9.     </Header>
  10.     <Snippet>
  11.       <References>
  12.         <Reference>
  13.           <Assembly>System.Xml.dll</Assembly>
  14.           <Url />
  15.         </Reference>
  16.       </References>
  17.       <Imports>
  18.         <Import>
  19.           <Namespace>System.IO</Namespace>
  20.         </Import>
  21.         <Import>
  22.           <Namespace>System.Xml</Namespace>
  23.         </Import>
  24.         <Import>
  25.           <Namespace>System.Xml.Schema</Namespace>
  26.         </Import>
  27.       </Imports>
  28.       <Declarations>
  29.     <Literal>
  30.       <ID>XmlFile</ID>
  31.       <Type>String</Type>
  32.       <ToolTip>Replace with the xml file to infer schema from.</ToolTip>
  33.       <Default>"sample.xml"</Default>
  34.     </Literal>
  35.     <Literal>
  36.       <ID>XsdFile</ID>
  37.       <Type>String</Type>
  38.       <ToolTip>Replace with the xsd filename to save the schema to.</ToolTip>
  39.       <Default>"sampleSchema.xsd"</Default>
  40.     </Literal>
  41.       </Declarations>
  42.       <Code Language="VB" Kind="method body"><![CDATA[' Gets the schema.
  43. Dim infer As New XmlSchemaInference()
  44. Dim sc As New XmlSchemaSet()
  45. sc = infer.InferSchema(New XmlTextReader($xmlFile$))
  46.  
  47. ' Writes the schema.
  48. Dim w As XmlWriter = XmlWriter.Create(New StreamWriter($XsdFile$))
  49. Dim schema As XmlSchema
  50. For Each schema In sc.Schemas()
  51.     schema.Write(w)
  52. Next schema]]></Code>
  53.     </Snippet>
  54.   </CodeSnippet>
  55. </CodeSnippets>